package com.gis507.test.intertest;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class AISInterDriver {

    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {

        //1、新建Job
        Configuration conf = new Configuration();

        //10、key和value之间使用"，"
        conf.set("mapred.textoutputformat.separator", ",");

        //11、mapreduce的内存设置
        conf.set("mapreduce.map.memory.mb","1024");
        conf.set("mapreduce.reduce.memory.mb","1024");

        Job job = Job.getInstance(conf);

        //2、设置jar包
        job.setJarByClass(AISInterDriver.class);

        //3、关联map和reduce关系
        job.setMapperClass(AISInterMapper.class);
        job.setReducerClass(AISInterReducer.class);

        //4、设置map的输出类型
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(AISInterBean.class);

        //5、设置最终的输出类型
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(AISInterBean.class);

//        //8、设置分区
//        job.setPartitionerClass(AISDataPartition.class);
//
//        //9、设置分区个数
//        job.setNumReduceTasks(5);

        //6、设置输入输出路径
        FileInputFormat.setInputPaths(job,new Path("D:\\AAUser\\dic\\Files\\testFile\\testmin.csv"));
        FileOutputFormat.setOutputPath(job,new Path("D:\\AAUser\\dic\\Files\\testFile2"));

        //7、提交job
        boolean result = job.waitForCompletion(true);
        System.exit(result ? 0:1);
    }
}
